const path = require("path");
const nodeExternals = require("webpack-node-externals");
const { VueLoaderPlugin } = require("vue-loader");
module.exports = {
    target: "node",
    mode: "development",
    entry: "./src/server/index.js",
    output: {
        filename: "server_bundle.js",
        path: path.resolve(__dirname, "../build/server"),
    },
    module: {
        rules: [
            {
                test: /\.js$/, // js结尾
                loader: "babel-loader",
                options: {
                    presets: ["@babel/preset-env"],
                },
            },
            {
                test: /\.vue$/, // vue结尾
                loader: "vue-loader",
            },
        ],
    },
    plugins: [new VueLoaderPlugin()],
    resolve: {
        // 添加了这些扩展名之后, 项目中导报如下的扩展名文件就不需要编写文件的后缀
        extensions: [".js", ".json", ".wasm", ".jsx", ".vue"],
    },

    // nodeExternals 排除大的包 比如express  不需要打包进去
    externals: [nodeExternals()], // 排除node modules

    // 修改脚本  pnpm run start  测试打包后的文件是否可以使用   --watch 监听文件 文件发生修改时 重新打包
};
